import time

import pytest
from appium import webdriver
from appium.options.android import UiAutomator2Options

from Pages.page_card_order import CardOrder
from Pages.page_enter_home import EnterHome
from Pages.page_log import PageLogin
from Pages.page_search import PageSearch
from config import AD_CAS


@pytest.fixture(scope="function")
def get_driver():
    des_caps = AD_CAS
    # 初始化设备配置信息
    option = UiAutomator2Options().load_capabilities(des_caps)
    # 创建驱动对象
    driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", options=option)
    driver.implicitly_wait(10)
    yield driver
    time.sleep(2)
    driver.quit()


@pytest.fixture
def login(get_driver):
    login = PageLogin(get_driver)
    login.login("18700000001", "test1234")


@pytest.fixture
def search(get_driver):
    search = PageSearch(get_driver)
    search.search_input_goods("手机")

@pytest.fixture
def cardOrder(get_driver):
    card_order = CardOrder(get_driver)
    card_order.card_order()
